/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.wins.vertx.entity;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

/**
 * Converter for {@link io.wins.vertx.entity.Goods}.
 *
 * NOTE: This class has been automatically generated from the {@link io.wins.vertx.entity.Goods} original class using Vert.x codegen.
 */
public class GoodsConverter {

  public static void fromJson(JsonObject json, Goods obj) {
    if (json.getValue("code") instanceof String) {
      obj.setCode((String)json.getValue("code"));
    }
    if (json.getValue("content") instanceof String) {
      obj.setContent((String)json.getValue("content"));
    }
    if (json.getValue("count") instanceof Number) {
      obj.setCount(((Number)json.getValue("count")).intValue());
    }
    if (json.getValue("createdOn") instanceof Number) {
      obj.setCreatedOn(((Number)json.getValue("createdOn")).longValue());
    }
    if (json.getValue("delete") instanceof Boolean) {
      obj.setDelete((Boolean)json.getValue("delete"));
    }
    if (json.getValue("imageList") instanceof String) {
      obj.setImageList((String)json.getValue("imageList"));
    }
    if (json.getValue("onSell") instanceof Boolean) {
      obj.setOnSell((Boolean)json.getValue("onSell"));
    }
    if (json.getValue("poster") instanceof String) {
      obj.setPoster((String)json.getValue("poster"));
    }
    if (json.getValue("price") instanceof Number) {
      obj.setPrice(((Number)json.getValue("price")).floatValue());
    }
    if (json.getValue("shortDesc") instanceof String) {
      obj.setShortDesc((String)json.getValue("shortDesc"));
    }
    if (json.getValue("title") instanceof String) {
      obj.setTitle((String)json.getValue("title"));
    }
    if (json.getValue("updatedOn") instanceof Number) {
      obj.setUpdatedOn(((Number)json.getValue("updatedOn")).longValue());
    }
  }

  public static void toJson(Goods obj, JsonObject json) {
    if (obj.getCode() != null) {
      json.put("code", obj.getCode());
    }
    if (obj.getContent() != null) {
      json.put("content", obj.getContent());
    }
    json.put("count", obj.getCount());
    json.put("createdOn", obj.getCreatedOn());
    json.put("delete", obj.isDelete());
    if (obj.getId() != null) {
      json.put("id", obj.getId());
    }
    if (obj.getImageList() != null) {
      json.put("imageList", obj.getImageList());
    }
    json.put("onSell", obj.isOnSell());
    if (obj.getPoster() != null) {
      json.put("poster", obj.getPoster());
    }
    json.put("price", obj.getPrice());
    if (obj.getShortDesc() != null) {
      json.put("shortDesc", obj.getShortDesc());
    }
    if (obj.getTitle() != null) {
      json.put("title", obj.getTitle());
    }
    json.put("updatedOn", obj.getUpdatedOn());
  }
}